﻿using System;
using System.Collections.Generic;
using StockLib.UserData;

namespace StockLib
{
    public class StockBlockGroupRegular : StockBlockGroup
    {
        /// <summary>
        /// 单例实例
        /// </summary>
        private static StockBlockGroupRegular _instance = new StockBlockGroupRegular();

        /// <summary>
        /// 构造函数
        /// </summary>
        private StockBlockGroupRegular()
            : base()
        {
        }

        /// <summary>
        /// 访问单例
        /// </summary>
        /// <returns></returns>
        public static StockBlockGroupRegular Instance
        {
            get
            {
                return _instance;
            }
        }

        /// <summary>
        /// 获取板块组
        /// </summary>
        public List<string> Groups
        {
            get
            {
                List<string> groupList = new List<string>();
                foreach (StockBlock block in this.Values)
                {
                    if (!groupList.Contains(block.GroupName))
                    {
                        groupList.Add(block.GroupName);
                    }
                }

                return groupList;
            }
        }

        /// <summary>
        /// 加载预定义板块组数据
        /// </summary>
        public override void Load()
        {
            StockUserData.Instance.LoadDomainData();
        }

        /// <summary>
        /// 保存预定义板块组数据
        /// </summary>
        public override void Save()
        {
            StockUserData.Instance.SaveDomainData();
        }
    }
}
